import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:hc_bio_sdk/hc_bio_sdk.dart';
import 'package:hc_bio_sdk_example/Bio/view.dart';
import 'package:hc_bio_sdk_example/Login/view.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      builder: (ctx, _) => GetMaterialApp(
          popGesture: true,
          debugShowCheckedModeBanner: false,
          defaultTransition: Transition.cupertino,
          initialRoute: "/login",
          builder: EasyLoading.init(),
          theme: ThemeData(
            useMaterial3: true,
            primaryColor: const Color(0xff0B77E1),
            appBarTheme: AppBarTheme(
              centerTitle: true,
              titleTextStyle: TextStyle(
                fontSize: 22.sp,
                color: Colors.black,
              ),
              //backgroundColor: Colors.transparent,
              //iconTheme: IconThemeData(color: Colors.white),
            ),
            textTheme: TextTheme(
              titleLarge: TextStyle(
                fontSize: 22.sp,
              ),
              titleMedium: TextStyle(
                fontSize: 18.sp,
              ),
              titleSmall: TextStyle(
                fontSize: 15.sp,
              ),
              labelLarge: TextStyle(
                fontSize: 12.sp,
              ),
            ),
            scaffoldBackgroundColor: const Color(0xFFF5F5F5),
            listTileTheme: ListTileThemeData(
              titleTextStyle: TextStyle(
                fontSize: 15.sp,
                fontWeight: FontWeight.bold,
              ),
              subtitleTextStyle: TextStyle(
                fontSize: 12.sp,
                color: Colors.black.withOpacity(0.5),
              ),
            ),
            outlinedButtonTheme: OutlinedButtonThemeData(
              style: OutlinedButton.styleFrom(
                foregroundColor: Colors.white,
                side: BorderSide.none,
                backgroundColor: const Color(0xff0B77E1),
                padding: EdgeInsets.symmetric(
                  vertical: 5.sp,
                  horizontal: 10.sp,
                ),
                textStyle: TextStyle(
                  color: Colors.white,
                  fontSize: 15.sp,
                ),
              ),
            ),
          ),
          initialBinding: _DefaultBinds(),
          onInit: () async {
            final sdk = Get.find<HcBioSdk>();
            sdk.initialize("zysdk");
          },
          getPages: [
            GetPage(
              name: "/login",
              page: () {
                return const LoginPage();
              },
            ),
            GetPage(
              name: "/bio",
              page: () {
                return const BioPage();
              },
            ),
          ]),
    );
  }
}

class _DefaultBinds extends Bindings {
  @override
  void dependencies() {
    Get.put<HcBioSdk>(
      HcBioSdk(),
      permanent: true,
    );
  }
}
